{extend name="layout/popup" /}

{block name="content"}
<input type="hidden" name="val" id="val">
<input type="hidden" name="name" id="name">
<div class="popup-header">
    <h1 class="popup-title">请选择配置分类</h1>
</div>
<div class="popup-body">
    <div class="tree-menu edit">
        {:tree_menu($menu_tree)}
    </div> 
</div>
<div class="popup-footer">
    <a class="layui-btn" onclick="save();">确定</a>
    <a class="layui-btn layui-btn-primary" onclick="popup_close();">取消</a>
</div>
{/block}

{block name="script"}
<script>
    layui.use(['jquery'], function () {
        var $ = layui.jquery;
        var fn = {
            save: function () {
                if ($("#name").val().length > 0) {
                    $("#config_tab_name", parent.document).val($("#name").val());
                    $("#config_tab_id", parent.document).val($("#val").val());
                } else {
                    parent.layer.msg('"请选择"');
                    return false;
                }
                popup_close();
            }
        };
        win_exp(fn);

        parent_node = $("#id", parent.document).val();
        $(".tree-menu a[node='" + parent_node + "']").addClass("disabled");
        $(".tree-menu a[node='" + parent_node + "'] + input + label + ul a").addClass("disabled");
        $(".tree-menu a:not('.disabled')").click(function () {
            $this = $(this);
            $("#val").val($this.attr("node"));
            $("#name").val($this.text());
            $(".tree-menu a.active").removeClass("active");
            $this.addClass("active");
        });
    });
</script>
{/block}
